//
//  JXBaseTableViewController.swift
//  swift高仿微博
//
//  Created by peijiaxing on 16/2/25.
//  Copyright © 2016年 peijiaxing. All rights reserved.
//

import UIKit

class JXBaseTableViewController: UITableViewController , JXVisitorDelegate {
    
//    var isLogin:Bool = false
    
    var visitor: JXVisitorView?
    
    var isLogin: Bool = JXUserViewModel.shareInstance.isLogin!
    
    override func loadView() {
        
        if JXUserViewModel.shareInstance.isLogin!{
            
            super.loadView()
        }else{
            loadVisitorView()
        }
    }
    
    // 加载视图
    private func loadVisitorView(){
        visitor = JXVisitorView()
        // 开始动画
        visitor?.startAnimation()
        
        //设置代理
        visitor?.delegate = self
        
        view = visitor
        
        setupNav()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    
    private func setupNav(){
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "didRegisterMethod")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "didLoginMethod")
        
    }
    func didRegisterMethod(){
        print("注册")
    
    }
    func didLoginMethod(){
        let ouath = JXOauthViewController()
        
        let  nav = UINavigationController(rootViewController: ouath)
        
        presentViewController(nav, animated: true) { () -> Void in
            
        }
    }

}
